<template>
  <div>
    <div class="qrcon">
      <iframe
        scrolling="no"
        :width="iframeW"
        :height="iframeH"
        frameborder="0"
        allowtransparency="true"
        :src="setSrc"
        ref="iframe"
      ></iframe>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        //用于保持请求和回调的状态
        state:'',
        appid:"wxf1c6ed468b10dad4",
        redirect_uri:encodeURIComponent('http://smart-build.cn/#/qrconnent')
      };
    },
    props:{
        // 自定义样式
        cssHref:{
            type:String,
            default:'https://iotx.oss-cn-beijing.aliyuncs.com/iotx/bg/bindcss.css'
        },
        //iframeH
        iframeH:{
            type:Number,
            default:230
        },
        //iframeW
        iframeW:{
            type:Number,
            default:200
        }
    },
    computed: {
      setSrc() {
        var _url =
          "https://open.weixin.qq.com/connect/qrconnect?appid=" +
          this.appid +
          "&self_redirect=true" +
          "&scope=snsapi_login" +
          "&redirect_uri=" +
          this.redirect_uri +
          "&state=" +
          this.state +
          "&login_type=jssdk&self_redirect=default&style=black" +
          "&href=" +
          this.cssHref;
        return _url;
      }
    },
    created(){
      this.state = new Date().getTime();
    },
    methods:{
      // 刷新二维码
      refresh(){
        this.state = new Date().getTime();
      }
    }
  };
</script>

<style lang="scss" scoped>

</style>